<template>
  <div class='wrap'>
    <div class='container w'>
      <div>
           <el-form ref="form" :model="form" label-width="80px" size="small" class="form">
           <el-form-item >
            新增:编辑收件地址
          </el-form-item>
          <el-form-item label="收件昵称"  placeholder="请输入收件姓名">
            <el-input v-model="form.name" maxlength="15"  show-word-limit></el-input>
          </el-form-item>
           <el-form-item label="手机号码" placeholder="请输入手机号码">
            <el-input v-model.number="form.phone"  maxlength="11"  show-word-limit></el-input>
          </el-form-item>
           <el-form-item label="地址信息" placeholder="请选择 省/市/区/街道">
            <el-cascader
              v-model="form.city"
              clearable
              :options="options"
              :props="{ expandTrigger: 'hover' }"
              @change="handleChange"></el-cascader>
          </el-form-item>
           <el-form-item label="详细地址" placeholder="请输入详细地址信息，如道路、门牌号、小区、楼栋号、单元等信息">
             <el-input type="textarea" v-model="form.desc"  :autosize="{ minRows: 4, maxRows: 4}"  maxlength="120"  show-word-limit></el-input>
          </el-form-item>
           <el-form-item >
            <el-checkbox v-model="form.checked">设置为默认收货地址</el-checkbox>
          </el-form-item>
          <el-form-item >
            <el-button type="primary" size="small">保存</el-button>
          </el-form-item>
        </el-form>
      </div>
        
      <div class="table">
         <el-alert
            :title="infoTitle"
            type="info"
            show-icon>
          </el-alert>
        <el-table
      :data="tableData"
      size="small"
      style="width: 100%">
      <el-table-column
        prop="name"
        label="收件昵称"
        align="center"
        width="180">
      </el-table-column>
       <el-table-column
        prop="phone"
        align="center"
        label="手机号码"
        width="180">
      </el-table-column>
      <el-table-column
        prop="city"
        align="center"
        label="地址信息">
      </el-table-column>
      <el-table-column
        prop="desc"
        align="center"
        label="详细地址">
      </el-table-column>
       <el-table-column
        label="默认地址"
        align="center"
        width="180">
        <template v-slot="slot">
          <el-link v-if="slot.row.checked" :underline="false" icon="el-icon-location-information">默认地址</el-link>
          <el-link v-else :underline="false">设为默认地址</el-link>
        </template>
      </el-table-column>
       <el-table-column
        label="操作"
        align="center"
        width="180">
        <template>
          <el-link :underline="false" icon="el-icon-edit">编辑</el-link>
          <el-link :underline="false" icon="el-icon-delete">删除</el-link>
        </template>
      </el-table-column>
    </el-table>
      </div>
    </div>
   </div>
</template>

<script>
  export default {
    name: 'ReceiveAddress',
    components: {},
    data() {
      return {
        form:{
          name:'',//收件姓名
          phone:'',//手机4号吗
          city:'',//城市
          checked:false,//是否为默认地址
          desc:''//详细地址
        },
        options: [{
          value: 'zhinan',
          label: '指南',
          children: [{
            value: 'shejiyuanze',
            label: '设计原则',
            children: [{
              value: 'yizhi',
              label: '一致'
            }, {
              value: 'fankui',
              label: '反馈'
            }, {
              value: 'xiaolv',
              label: '效率'
            }, {
              value: 'kekong',
              label: '可控'
            }]
          }, {
            value: 'daohang',
            label: '导航',
            children: [{
              value: 'cexiangdaohang',
              label: '侧向导航'
            }, {
              value: 'dingbudaohang',
              label: '顶部导航'
            }]
          }]
        }, {
          value: 'zujian',
          label: '组件',
          children: [{
            value: 'basic',
            label: 'Basic',
            children: [{
              value: 'layout',
              label: 'Layout 布局'
            }, {
              value: 'color',
              label: 'Color 色彩'
            }, {
              value: 'typography',
              label: 'Typography 字体'
            }, {
              value: 'icon',
              label: 'Icon 图标'
            }, {
              value: 'button',
              label: 'Button 按钮'
            }]
          }, {
            value: 'form',
            label: 'Form',
            children: [{
              value: 'radio',
              label: 'Radio 单选框'
            }, {
              value: 'checkbox',
              label: 'Checkbox 多选框'
            }, {
              value: 'input',
              label: 'Input 输入框'
            }, {
              value: 'input-number',
              label: 'InputNumber 计数器'
            }, {
              value: 'select',
              label: 'Select 选择器'
            }, {
              value: 'cascader',
              label: 'Cascader 级联选择器'
            }, {
              value: 'switch',
              label: 'Switch 开关'
            }, {
              value: 'slider',
              label: 'Slider 滑块'
            }, {
              value: 'time-picker',
              label: 'TimePicker 时间选择器'
            }, {
              value: 'date-picker',
              label: 'DatePicker 日期选择器'
            }, {
              value: 'datetime-picker',
              label: 'DateTimePicker 日期时间选择器'
            }, {
              value: 'upload',
              label: 'Upload 上传'
            }, {
              value: 'rate',
              label: 'Rate 评分'
            }, {
              value: 'form',
              label: 'Form 表单'
            }]
          }, {
            value: 'data',
            label: 'Data',
            children: [{
              value: 'table',
              label: 'Table 表格'
            }, {
              value: 'tag',
              label: 'Tag 标签'
            }, {
              value: 'progress',
              label: 'Progress 进度条'
            }, {
              value: 'tree',
              label: 'Tree 树形控件'
            }, {
              value: 'pagination',
              label: 'Pagination 分页'
            }, {
              value: 'badge',
              label: 'Badge 标记'
            }]
          }, {
            value: 'notice',
            label: 'Notice',
            children: [{
              value: 'alert',
              label: 'Alert 警告'
            }, {
              value: 'loading',
              label: 'Loading 加载'
            }, {
              value: 'message',
              label: 'Message 消息提示'
            }, {
              value: 'message-box',
              label: 'MessageBox 弹框'
            }, {
              value: 'notification',
              label: 'Notification 通知'
            }]
          }, {
            value: 'navigation',
            label: 'Navigation',
            children: [{
              value: 'menu',
              label: 'NavMenu 导航菜单'
            }, {
              value: 'tabs',
              label: 'Tabs 标签页'
            }, {
              value: 'breadcrumb',
              label: 'Breadcrumb 面包屑'
            }, {
              value: 'dropdown',
              label: 'Dropdown 下拉菜单'
            }, {
              value: 'steps',
              label: 'Steps 步骤条'
            }]
          }, {
            value: 'others',
            label: 'Others',
            children: [{
              value: 'dialog',
              label: 'Dialog 对话框'
            }, {
              value: 'tooltip',
              label: 'Tooltip 文字提示'
            }, {
              value: 'popover',
              label: 'Popover 弹出框'
            }, {
              value: 'card',
              label: 'Card 卡片'
            }, {
              value: 'carousel',
              label: 'Carousel 走马灯'
            }, {
              value: 'collapse',
              label: 'Collapse 折叠面板'
            }]
          }]
        }, {
          value: 'ziyuan',
          label: '资源',
          children: [{
            value: 'axure',
            label: 'Axure Components'
          }, {
            value: 'sketch',
            label: 'Sketch Templates'
          }, {
            value: 'jiaohu',
            label: '组件交互文档'
          }]
        }],
        tableData: [{
            name: '王小虎',
            phone: '13888888888',
            city:'广东省广州市白云区',
            desc: '金沙江路 1518 弄',
            checked:false,
          },
          {
            name: '李白',
            phone: '13988888888',
            city:'广东省广州市白云区',
            desc: '金沙江路 1518 弄',
            checked:true,
          },{
            name: '杜甫',
            phone: '13888888888',
            city:'广东省广州市白云区',
            desc: '金沙江路 1518 弄',
            checked:false,
          },{
            name: '王小虎',
            phone: '13888888888',
            city:'广东省广州市白云区',
            desc: '金沙江路 1518 弄',
            checked:false,
          }]
      };
    },
    created() {},
    computed:{
      infoTitle(){
        return `已保存了${this.tableData.length}条地址，还能保存${10 - this.tableData.length}条地址`
      }
    },
    methods: {
      handleChange(value) {
        console.log(value);
      }
    }, 
  };
</script>
<style lang="scss" scoped>
.container{
  background-color:#fff;
  
  // div{
  //   width: 100%;
  // }
}
.form{
  width: 50%;
}
.table{
  margin-top: 40px;
  padding: 15px;
  // width: 90%;
  .el-alert{
    margin-bottom: 15px;
  }
}
</style>